package com.xinqing.test.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author CHQ
 * @date
 * @description
 */
public class ThreadLocalUtils {
    private static java.lang.ThreadLocal<Map> holder = new java.lang.ThreadLocal<Map>();

    public static <T> T get(String key) {
        if (holder.get().get(key) == null || holder.get() == null) {
            return null;
        }
        return (T) holder.get().get(key);
    }

    public static void set(String key, Object value) {
        if (holder.get() == null) {
            holder.set(new HashMap());
            holder.get().put(key, value);
        }
        holder.get().put(key, value);
    }
}
